
function listRender(data, cont){
  let str = "";
  data.forEach(val=>{
    str += `<div class="box" data-id="${val.goodsId}">
              <img src="${val.goodsImg}" alt="">
              <span>${val.goodsName}</span>
              <p>${val.price}</p>
              <input type="button" value="加入购物车" class="add">
            </div>`
  })
  cont.innerHTML = str;
}
export { listRender };

function cartRender(data, localData, cont){
  let str = "";
  data.forEach(goods=>{
    localData.forEach(cart=>{
      if(goods.goodsId === cart.id){
        str += `<tr data-id="${cart.id}">
                  <td align="center"><input type="checkbox" class="check" ${cart.check ? 'checked' : ''}></td>
                  <td><img src="${goods.goodsImg}" alt=""></td>
                  <td>${goods.goodsName}</td>
                  <td><input type="number" class="setNum" value="${cart.num}"></td>
                  <td>${cart.price}</td>
                  <td class="count">${cart.num * cart.price}</td>
                  <td><span class="del">删除</span></td>
                </tr>`
      }
    })
  })
  cont.innerHTML = str;
}
export { cartRender };